Computers / Programming / Language References / Assembly / MOS 6502

MOS 6502 Architecture
MOS 6502 Instruction Set

Overview

The 6502 is a microprocessor released by MOS Technology in 1975. It was designed as a cheaper version of the Motorola 6800 and many of the designers from the Motorola project also worked on the 6502. Being simpler and cheaper than its rivals it found widespread use in 8-bit microcomputers like the Commodore PET, Commodore 64, NES, BBC Micro, Apple II and the Atari 8-bit line.

The following information is based on the VASM assembler for the 6502 with the oldstyle syntax module and -dotdir enabled

Source Line Format

The format of instructions in 6502 assembly is

[Label:] Opcode [Operand[,Operand]] [;Comment]

Label

The label field is used to identify the instruction for use by other instructions and corresponds to the location of that instruction

A label can be any alphabetical or the special characters including '_'

The label is terminated with a colon

Opcode

The opcode field contains the nonmuonic for the instruction or assembler directive and must be separated from the label with whitespace even if the label is blank

Operands

Operands are arguments to the instruction or directive. If multiple operands are specified then they should be separated by commas

Comments

The comment field contains information used to annotate and describe the program. It is preceded by a semicolon and may contain any printable character

Number Literals

Hexadecimal values are prefixed with $

Binary values are prefixed with %

Octal values are prefixed with @

Directives

equ or =

Defines a compiler symbol and assigns it a value

symbol = value

.org

Sets the current origin for assembling instructions

.org value

.byte

Places the byte value at the current location

.byte value[,value…]

.word

Places the 16-bit value at the current location

.word value[,value…]